<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>

    <script type="application/javascript" src="../js/jquery-1.11.1.min.js"></script>

</head>
<body>
<div style="padding: 30px;">

    <a href="list.html"> 返回列表 </a>


    <h1> 修改信息 </h1>


    <form id="zzyForm">
        id:<input id="id" name="id" type="text" readonly value=""/><br/><br/>
        类名字:<input id="cronKey"  name="cronKey" type="text" value=""/>
        <br/><br/>
        表达式:<input  id="cronExpression"  name="cronExpression" type="text" value=""/><br/><br/>
        说明:<input id="taskExplain"  name="taskExplain" type="text" value=""/><br/><br/>
        状态(0,1):<input id="status"  name="status" type="number" value=""/><br/><br/>
    </form>
    <br/><br/>
    <button onclick="update()">提交</button>
</div>
</body>

<script>
    //获取url中的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg); //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    var id = getUrlParam('id');


    $(function () {

        $("#id").val(id);

        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:8084/scheduled/get",
            dataType:"json",
            data: {"id":id},
            async: false,
            success: function (data) {
                $("#id").val(data.id);
                $("#cronKey").val(data.cronKey);
               $("#cronExpression").val(data.cronExpression);
                $("#taskExplain").val(data.taskExplain);
                $("#status").val(data.status);
            },
            error: function(data) {
                console.log("出错："+data);
            }
        });



    });

    function update() {
        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:8084/scheduled/update",
            dataType:"json",
            data:$("#zzyForm").serialize(),
            async: false,
            success: function (data) {
                console.log(data.msg)
                alert(data.msg);
            },
            error: function(data) {
                console.log("出错："+data);
            }
        });
    }
</script>

</html>